/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entity.structure;

/**
 *
 * @author dell
 */
import entity.support.Area;
import entity.support.Obj;
import java.text.ParseException;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.HashMap;
public class Device extends Obj
{
//columns_______________________________________________________________________
private String code;
private int type;
private String sim;
private int protocoltype;
private int heart;
private Area area;
private int facilityid;
private Date validatetime;
private String productcompany;
private String productcontact;
private String servicecompany;
private String servicecontact;
private String remark;
//functions_____________________________________________________________________
     //operator_________________________________________________________________
public Device()
{
     
}
public Device(Obj o)
{
     
}
public Device(Map<String,String> map) throws ParseException
{
     this.code=map.get("code");
     this.sim=map.get("sim");
     this.name=map.get("name");
     
     this.protocoltype=Integer.valueOf(map.get("protocol_type"));
     this.facilityid=Integer.valueOf(map.get("facility_id"));
     this.id=Integer.valueOf(map.get("id"));
     this.type=Integer.valueOf(map.get("type"));
     this.heart=Integer.valueOf(map.get("heart"));    
     
     SimpleDateFormat s=new SimpleDateFormat();
     try
     {
         this.validatetime=s.parse(map.get("validate_time"));
         this.intime=s.parse(map.get("in_time"));
         this.updatetime=s.parse(map.get("update_time"));
     }
     catch(Exception e)
     {
         System.out.println(e);
     }
     
     String des=map.get("area_description");
     double longt=Double.valueOf(map.get("area_longtitude"));
     double lat=Double.valueOf(map.get("area_latitude"));
     this.area=new Area(des,longt,lat);
}
     //getter___________________________________________________________________
public String getCode() 
{
     return code;
}
public int getType() 
{
     return type;
}
public String getSim() 
{
     return sim;
}
public int getProtocoltype() 
{
     return protocoltype;
}
public int getHeart() 
{
     return heart;
}
public Area getArea() 
{
     return area;
}
public int getFacilityid() 
{
     return facilityid;
}
public Date getValidatetime() 
{
     return validatetime;
}
public String getProductcompany() 
{
     return productcompany;
}
public String getProductcontact() 
{
     return productcontact;
}
public String getServicecompany() 
{
     return servicecompany;
}
public String getServicecontact() 
{
     return servicecontact;
}
public String getRemark() 
{
     return remark;
}
     //setter___________________________________________________________________
public void setCode(String code) 
{
     this.code = code;
}
public void setType(int type) 
{
     this.type = type;
}
public void setSim(String sim) 
{
     this.sim = sim;
}
public void setProtocoltype(int protocoltype) 
{
     this.protocoltype = protocoltype;
}
public void setHeart(int heart) 
{
     this.heart = heart;
}
public void setArea(Area area) 
{
     this.area = area;
}
public void setFacilityid(int facilityid) 
{
     this.facilityid = facilityid;
}
public void setValidatetime(Date validatetime) 
{
     this.validatetime = validatetime;
}
public void setProductcompany(String productcompany) 
{
     this.productcompany = productcompany;
}
public void setProductcontact(String productcontact) 
{
     this.productcontact = productcontact;
}
public void setServicecompany(String servicecompany) 
{
     this.servicecompany = servicecompany;
}
public void setServicecontact(String servicecontact) 
{
     this.servicecontact = servicecontact;
}
public void setRemark(String remark) 
{
     this.remark = remark;
}
     //operator_________________________________________________________________
public Map<String,String> getProductContactInMap()
{
     return StructureUtil.toMap(this.productcontact);
}
public Map<String,String> getServiceContactInMap()
{
     return StructureUtil.toMap(this.servicecontact);
}
     //toString_________________________________________________________________
@Override
public String toString()
{
     return super.toString()+"\t"+code+"\t"+type+"\t"+sim+"\t"+protocoltype+"\t"
             +heart+"\t"+area+facilityid+"\t"+validatetime+"\t"+productcompany+"\t"
             +productcontact+"\t"+servicecompany+"\t"+servicecompany+"\t"
             +servicecontact+"\t"+remark;
}
}
